package com.wgj.android.accesslibility.config;

import android.content.Context;

import com.jiaai.xui.cache.XCache;
import com.jiaai.xui.utils.XPreferencesUtils;

import java.util.ArrayList;

/**
 * Created by Administrator on 2017/12/9.
 */

public class WXConfginUtil {
    public static final String IS_CLEAN_FIRENDS= "IS_CLEAN_FIRENDS";//清粉过虑人数
    public static final String IS_CLEAN_FIRENDS_FILTER = "IS_CLEAN_FIRENDS_FILTER";//清粉过虑人数
    public static final String CHECK_NUMLBER = "CHECK_NUMLBER";//每次检测人数

    /**
     * 是否已开启清粉功能
     * @return
     */
    public  static boolean isOpenCleanFirend(){
        return (boolean) XPreferencesUtils.get(IS_CLEAN_FIRENDS,false);
    }

    /**
     * 开启和关闭清粉功能
     * @param v
     */
    public static void setIsOpenCleanFirend(boolean v){
        XPreferencesUtils.put(IS_CLEAN_FIRENDS,v);
    }

    /**
     * 是否已开启清粉过滤
     * @return
     */
    public  static boolean isOpenCleanFirendFilter(){
         return (boolean) XPreferencesUtils.get(IS_CLEAN_FIRENDS_FILTER,true);
    }

    /**
     * 开启和关闭清粉过滤功能
     * @param v
     */
    public static void setIsOpenCleanFirendFilter(boolean v){
        XPreferencesUtils.put(IS_CLEAN_FIRENDS_FILTER,v);
    }

    /**
     * 获取清粉每次检测人数设置
     * @return
     */
    public static int  getCheckNumber(){
        return (int) XPreferencesUtils.get(CHECK_NUMLBER,200);
    }

    /**
     * 设置清粉每次检测人数
     * @param numlber
     */
    public static void  setCheckNumlber(int numlber){
        XPreferencesUtils.put(CHECK_NUMLBER,numlber);
    }

    /**
     * 是否开启红包功能
     * @return
     */
    public  static boolean isOpenQhb(){
      return (boolean) XPreferencesUtils.get("isOpenQhb",false);
    }

    /**
     * 打开红包功能
     */
    public  static void openQhb(){
          XPreferencesUtils.put("isOpenQhb",true);
    }

    /**
     * 关闭红包功能
     */
    public  static void closeQhb(){
          XPreferencesUtils.put("isOpenQhb",false);
    }

    /**
     * 是否已打开基于定位的群加好友功能
     * @return
     */
    public  static boolean isOpenAddFriendByLocation(){
        return (boolean) XPreferencesUtils.get("isOpenAddFriend",false);
    }

    /**
     * 打开基于定位的群加好友功能
     */
    public  static void openAddFriendByLocation(){
        XPreferencesUtils.put("isOpenAddFriend",true);
    }

    /**
     * 关闭基于定位的群加好友功能
     */
    public  static void closeAddFriendByLocation(){
        XPreferencesUtils.put("isOpenAddFriend",false);
    }



    /**
     * 是否开启微信群内加好友功能
     * @return
     */
    public  static boolean isOpenAddFriendsByGropu(){
        return (boolean) XPreferencesUtils.get("isOpenAddFriendsByGropu",false);
    }

    /**
     * 打开红包功能
     */
    public  static void openAddFriendsByGropu(){
        XPreferencesUtils.put("isOpenAddFriendsByGropu",true);
    }

    /**
     * 关闭红包功能
     */
    public  static void closeAddFriendsByGropu(){
        XPreferencesUtils.put("isOpenAddFriendsByGropu",false);
    }


    /**
     * 返回群加好友设置
     * @return
     */
    public static  BatchGroupConfig getBatchGroupConfig(Context context){
        BatchGroupConfig config=(BatchGroupConfig)XCache.get(context).getAsObject("BatchGroupConfig");
        if(config==null){
            config=new BatchGroupConfig();
        }
        return config;
    }

    /**
     * 保存群加好友设置
     * @param config
     */
    public  static void saveBatchGroupConfig(Context context,BatchGroupConfig config){
        XCache.get(context).put("BatchGroupConfig",config);
    }

    /**
     * 返回附近群加好友设置
     * @return
     */
    public static  BatchLocationConfig getBatchLocationConfig(Context context){
        BatchLocationConfig config= (BatchLocationConfig) XCache.get(context).getAsObject("BatchLocationConfig");
        if(config==null){
            config=new BatchLocationConfig();
        }
        return config;
    }
    public  static void saveBatchLocationConfig(Context context,BatchLocationConfig config){
        XCache.get(context).put("BatchLocationConfig",config);
    }

    public static   void saveLocationFriends(Context context, ArrayList<String> nickNames){
         XCache.get(context).put("AddLocationFriends",nickNames);
    }

    public static ArrayList<String>  getLocationFriends(Context context){
        ArrayList<String> nickNames= (ArrayList<String>) XCache.get(context).getAsObject("AddLocationFriends");
        if(nickNames==null){
            nickNames=new ArrayList<>();
        }
        return nickNames;
    }


    public  static boolean isNotTipsWindowPermission(Context context){
        return (boolean) XPreferencesUtils.get("isNotTipsWindowPermission",false);
    }
    public  static void setIsNotTipsWindowPermission(Context context,boolean f){
         XPreferencesUtils.put("isNotTipsWindowPermission",f);
    }
}
